package com.xiaoshuidi.cloud.module.report.controller.ajreport;


import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.report.controller.ajreport.vo.*;
import com.xiaoshuidi.cloud.module.report.controller.finance.vo.ExportRespVO;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.ajreport.LedgerReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

/**
 * 在租台账、转租台账、续租台账、退租台账
 */

@Slf4j
@Tag(name = "报表 - 台账报表")
@RestController
@RequestMapping(ApiConstants.PREFIX+"/ledger")
public class LedgerReportController {

    @Resource
    private LedgerReportService ledgerReportService;

    @PostMapping("/rentingLedgerPage")
    @Operation(summary = "在租台账分页查询")
    public CommonResult<PageResult<RentingLedgerRespVO>> rentingLedgerPage(@RequestBody @Valid LedgerReportReqVO reqVO) {
        log.info("rentingLedgerPage req:{}",reqVO.toString());
        PageResult<RentingLedgerRespVO> pageResult = ledgerReportService.rentingLedgerPage(reqVO);
        return success(pageResult);
    }


    @PostMapping("/renewalLedgerPage")
    @Operation(summary = "续租台账分页查询")
    public CommonResult<PageResult<RenewalLedgerRespVO>> renewalLedgerPage(@RequestBody @Valid RenewalLedgerReportReqVO reqVO) {
        log.info("renewalLedgerPage req:{}",reqVO.toString());
        PageResult<RenewalLedgerRespVO> pageResult = ledgerReportService.renewalLedgerPage(reqVO);
        return success(pageResult);
    }


    @PostMapping("/exchangeLedgerPage")
    @Operation(summary = "换租台账分页查询")
    public CommonResult<PageResult<ExchangeLedgerRespVO>> exchangeLedgerPage(@RequestBody @Valid LedgerReportReqVO reqVO) {
        log.info("exchangeLedgerPage req:{}",reqVO.toString());
        PageResult<ExchangeLedgerRespVO> pageResult = ledgerReportService.exchangeLedgerPage(reqVO);
        return success(pageResult);
    }


    @PostMapping("/rentingOutLedgerPage")
    @Operation(summary = "退租台账分页查询")
    public CommonResult<PageResult<RentingOutLedgerRespVO>> rentingOutLedgerPage(@RequestBody @Valid LedgerReportReqVO reqVO) {
        log.info("rentingOutLedgerPage req:{}",reqVO.toString());
        PageResult<RentingOutLedgerRespVO> pageResult = ledgerReportService.rentingOutLedgerPage(reqVO);
        return success(pageResult);
    }


    /**
     * 在租台账导出
     *
     * @return
     */
    @PostMapping("/rentingLedgerExport")
    @Operation(summary = "在租台账导出")
    public CommonResult<ExportRespVO> rentingLedgerExport(@RequestBody @Valid LedgerReportReqVO req) {
        log.info("rentingLedgerExport req:{}",req.toString());
       return CommonResult.success(ledgerReportService.rentingLedgerExport(req));
    }

    /**
     * 续租台账导出
     *
     * @return
     */
    @PostMapping("/renewalLedgerExport")
    @Operation(summary = "续租台账导出")
    public CommonResult<ExportRespVO> renewalLedgerExport(@RequestBody @Valid RenewalLedgerReportReqVO req) {
        log.info("renewalLedgerExport req:{}",req.toString());
        return CommonResult.success(ledgerReportService.renewalLedgerExport(req));
    }

    /**
     * 换租台账导出
     *
     * @return
     */
    @PostMapping("/exchangeLedgerExport")
    @Operation(summary = "换租台账导出")
    public CommonResult<ExportRespVO> exchangeLedgerExport(@RequestBody @Valid LedgerReportReqVO req) {
        log.info("exchangeLedgerExport req:{}",req.toString());
        return CommonResult.success(ledgerReportService.exchangeLedgerExport(req));
    }

    /**
     * 退租台账导出
     *
     * @return
     */
    @PostMapping("/rentingOutLedgerExport")
    @Operation(summary = "退租台账导出")
    public CommonResult<ExportRespVO> rentingOutLedgerExport(@RequestBody @Valid LedgerReportReqVO req) {
        log.info("rentingOutLedgerExport req:{}",req.toString());
        return CommonResult.success(ledgerReportService.rentingOutLedgerExport(req));
    }

}
